package com.cnebula.openapi.auth.vo;

import io.vertx.core.json.JsonObject;

public class AccessToken {
	
	public String token;
	public long expire;
	public String refreshToken;
	public long reExpire;
	public String userId;
	public String userName;
	public String clientKey;
	public String tenantId;
	
	public String toString(){
		
		JsonObject obj = new JsonObject();
		obj.put("access_token", token);
		obj.put("expires_in", expire);
		obj.put("refresh_token", refreshToken);
		obj.put("re_expires_in", reExpire);
		obj.put("user_id", userId);
		obj.put("user_name", userName);
		
		return obj.toString();
	}
	
	public static AccessToken deserialize(String str){
		JsonObject obj = new JsonObject(str);
		AccessToken accessToken = obj.mapTo(AccessToken.class);
		return accessToken;
	}
	
	public String serialized(){
		JsonObject obj = JsonObject.mapFrom(this);
		return obj.toString();
	}
}
